﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Microsoft.Practices.Unity;

namespace Framework
{
	public class UnityDependencyResolver : IDependencyResolver
	{
		private readonly IUnityContainer container;

		public UnityDependencyResolver(IUnityContainer container)
		{
			this.container = container;
		}

		public object GetService(Type serviceType)
		{
			return container.IsRegistered(serviceType) ? container.Resolve(serviceType) : null;
		}

		public IEnumerable<object> GetServices(Type serviceType)
		{
			return container.IsRegistered(serviceType) ? container.ResolveAll(serviceType) : new List<object>();
		}
	}

}
